package com.woniu.cq.medical.dao;

import com.woniu.cq.medical.controller.form.ActForm;
import com.woniu.cq.medical.entity.ActOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Lucas
 * @since 2020-09-10
 */
public interface ActOrderMapper extends BaseMapper<ActOrder> {

    @Select("select p.patient_name,p.patient_age,p.patient_sex,c.case_id\n" +
            "from lonbon_patient p left join lonbon_case c on\n" +
            " p.patient_id=c.user_id where case_is_pigeonhole='否' and\n" +
            "p.patient_id_card=#{patientCardId}")
    ActForm selectPatient(String patientCardId);


    @Select("select a.act_order_id,p.patient_name,p.patient_age,p.patient_sex,c.case_id,\n" +
            "a.act_order_type,a.act_order_start_time,a.act_order_end_time,\n" +
            "a.act_order_result,d.doctor_name from lonbon_patient p left join \n" +
            "lonbon_case c on p.patient_id=c.user_id left join lonbon_act_order a\n" +
            "on c.case_id=a.case_id left join lonbon_doctor d on a.doctor_id=d.doctor_id\n" +
            "where p.patient_id_card=#{patientIdCase} and c.case_id=#{caseId}")
    ActForm seleAct(String patientIdCase, int caseId);

    @Select("select * from lonbon_act_order where patient_id_card=#{patientCardId}\n" +
            "and case_id=#{caseId}")
    ActOrder selectActOne(String patientCardId, int caseId);

    @Select("select doctor_id from lonbon_doctor where doctor_name=#{doctorName}")
    int selectByName(String doctorName);
}
